//
//  EXFirstFourViewController.m
//  Exercise
//
//  Created by 羊谦 on 16/6/20.
//  Copyright © 2016年 NetEase-yangqian. All rights reserved.
//

#import "EXFirstFourViewController.h"
#import "EXRefreshView.h"

@interface EXFirstFourViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tableview;

@end

@implementation EXFirstFourViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.width, self.view.height) style:UITableViewStylePlain];
    tableview.delegate = self;
    tableview.dataSource = self;
    [tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:tableview];
    self.tableview = tableview;
    EXRefreshView *refreshView = [[EXRefreshView alloc] initWithTableview:self.tableview target:self action:@selector(printLog)];
    self.tableview.tableHeaderView = refreshView;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

- (void)printLog {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [((EXRefreshView *)self.tableview.tableHeaderView) endRefresh];
    });
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.contentView.backgroundColor = [UIColor redColor];
    return cell;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
